{% assign data = section.settings %}
{%- capture fill_container -%}
  {%- if data.is_fill -%}
    full_container_wrapper
  {%- else -%}
    container_wrapper
  {%- endif -%}
{%- endcapture -%}
<div class="block_collection">
    <div class="{{fill_container}}">
        {% include 'title',title: data.block_title,detail: data.block_detail,more_text: data.more_text,more_href: '/collections' %}
        <div class="content" style="--pc-number: {{data.pc_number}};--mobile-number: {{data.yd_number}};--text-color: {{ data.text_color }};">
            <ul class="list grid md:gap-[30px] gap-[10px]">
				{% for block in section.blocks %}
					{% get_collection collections_id={block.collection.id} collection_image=1 %}
					{%- capture handle -%}
					  {% if collection.handle %}/collections/{{ collection.handle }}?data_from={{data_from}}
						{% else %}javascript:;{% endif %}
					{%- endcapture -%}
					<li class="list_item">
						<a href="{{handle}}" class="grid">
							<div class="img_box relative overflow-hidden">
								{%- if collection.image_alt == "" -%}
									{% assign collection_alt = collection | image_alt:'collection'   %}
								{%- else -%}
									{% assign collection_alt = collection.image_alt %}
								{%- endif -%}
								{% include 'lazy_img',src: collection.src,class: 'w-full h-full object-cover',alt:collection_alt %}
								<div class="mask absolute w-full h-full left-0 top-0 box-border" style="--bg: {{ data.mask_bg }}"></div>
							</div>
							{% if data.show_title %}
							<div class="text_box relative z-10 title_family flex items-center justify-center">
								<span>{{collection.title | default: 'Collection title'}}</span>
							</div>
							{% endif %}
						</a>
					</li>
				{% endfor %}
			</ul>
        </div>
    </div>
</div>

{% schema %}
{
	"tag": "section",
	"class": "block_collection",
	"is_global": false,
	"name": {
		"zh_CN": "专辑列表",
		"en_US": "Collection list"
	},
	"max_blocks": "20",
	"settings": [
		{
			"type": "card_header",
			"label": {
				"zh_CN": "设置",
				"en_US": "Settings"
			}
		},
		{
			"type": "card_switch",
			"label": {
				"zh_CN": "宽度铺满",
				"en_US": "Spread the width"
			},
			"id": "is_fill",
			"default": "false"
		},
		{
			"type": "card_input",
			"id": "block_title",
			"label": {
				"zh_CN": "标题",
				"en_US": "Title"
			},
			"placeholder": {
				"zh_CN": "请输入标题",
				"en_US": "Please enter title"
			},
			"default": ""
		},
		{
			"type": "card_text_editor",
			"id": "block_detail",
			"label": {
				"zh_CN": "简短描述",
				"en_US": "Short description"
			},
			"placeholder": {
				"zh_CN": "请输入描述",
				"en_US": "Please enter a description"
			},
			"default": ""
		},
		{
			"type": "card_switch",
			"label": {
			  "zh_CN": "显示专辑标题",
			  "en_US": "Show collection title"
			},
			"default": true,
			"id": "show_title"
		},
		{
			"type": "card_slider",
			"id": "pc_number",
			"max": "6",
			"min": "3",
			"label": {
				"zh_CN": "PC每排数量",
				"en_US": "PC number per row"
			},
			"default": "3"
		},
		{
			"type": "card_slider",
			"id": "yd_number",
			"max": "2",
			"min": "1",
			"label": {
				"zh_CN": "移动端每排数量",
				"en_US": "Number of mobile terminals per row"
			},
			"default": "2"
		},
		{
			"type": "card_color",
			"id": "text_color",
			"label": {
				"zh_CN": "文字颜色",
				"en_US": "text color"
			},
			"default": "#1D1F21"
		},
		{
			"type": "card_color",
			"label": {
				"zh_CN": "蒙层颜色",
				"en_US": "Mask color"
			},
			"id": "mask_bg",
			"show-alpha": "false",
			"color-format": "rgb",
			"default": "rgba(0,0,0,0)"
		},
		{
			"type": "card_input",
			"id": "more_text",
			"label": {
				"zh_CN": "查看更多文案",
				"en_US": "Text of view more"
			},
			"default": "VIEW MORE"
		},
		{
			"type": "card_header",
			"label": {
				"zh_CN": "内容",
				"en_US": "Content"
			}
		}
	],
	"blocks": [
		{
			"name": {
				"zh_CN": "选择专辑",
				"en_US": "Select collection"
			},
			"type": "collection-item",
			"settings": [
				{
					"type": "card_collection",
					"label": {
						"zh_CN": "专辑",
						"en_US": "Collection"
					},
					"default": {
						"id": "",
						"title": ""
					},
					"id": "collection"
				}
			]
		}
	],
	"default": {
		"settings": {
			"block_title": "",
			"block_detail": "",
			"show_title": true,
			"is_fill": false,
			"pc_number": "3",
			"yd_number": "1",
			"text_color": "#1D1F21",
			"mask_bg": "rgba(0,0,0,0)",
			"more_text": ""
		},
		"blocks": [
			{
				"collection": {
					"id": "",
					"title": ""
				},
				"block_type": "collection-item"
			},
			{
				"collection": {
					"id": "",
					"title": ""
				},
				"block_type": "collection-item"
			},
			{
				"collection": {
					"id": "",
					"title": ""
				},
				"block_type": "collection-item"
			}
		]
	},
	"icon": "icon-shangpinpingpu"
}
{% endschema %}